package mq.rabbitmq.d_topic;

import com.rabbitmq.client.*;
import mq.rabbitmq.ConnectionUtil;
import mq.rabbitmq.MqConstants;
import mq.rabbitmq.MyDefaultConsumer;

import java.io.IOException;
import java.util.concurrent.TimeoutException;

/**
 * @author shanzhenbo
 */
public class Consumer1 {

	public static void main(String[] args) throws Exception {
		Connection connection = ConnectionUtil.getConnection();
		Channel channel = connection.createChannel();
		channel.exchangeDeclare(MqConstants.TOPIC_EXCHANGE,
				BuiltinExchangeType.TOPIC);
		channel.queueDeclare(MqConstants.TOPIC_QUEUE_1, true, false, false, null);
		channel.queueBind(MqConstants.TOPIC_QUEUE_1, MqConstants.TOPIC_EXCHANGE, "item.update");
		channel.queueBind(MqConstants.TOPIC_QUEUE_1, MqConstants.TOPIC_EXCHANGE, "item.delete");
		MyDefaultConsumer consumer = new MyDefaultConsumer(channel, "消费者1");
		channel.basicConsume(MqConstants.TOPIC_QUEUE_1, true, consumer);
	}

}
